package org.spcloud.service.order.controller;

import java.util.HashMap;
import java.util.Map;

import org.spcloud.service.order.config.message.MessageBinding;
import org.spcloud.service.order.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
public class OrderController {

//	@Autowired
//	UserService userService;
	@Autowired
	MessageService messageService;
	
	@Autowired
	MessageBinding messageBinding;
	
	@Autowired
	RestTemplate restTemplate;
	
	@GetMapping("/order")
	public String order(){
		
		messageService.send("下单成功!");
		return "order";
	}
	
	@GetMapping("/findorder")
	public String findOrder(Integer id){
		
		messageBinding.smsSenderUser().send(MessageBuilder.withPayload("注册成功!").build());
		
		return "order:1";
	}
	
	@GetMapping("/hello")
	public String hello(String name){
		
		return restTemplate.getForObject("http://SPCLOUD-SERVICE-USER/hello?name="+name,String.class);//userService.hello(name);
	}
}
